<?php
include_once('../config.php');

global $CLAN_NAME;

if ($CLAN_NAME != '') {
    $dyn_width = (strlen($CLAN_NAME) * 38);    
    
    //generate image
    $image = imagecreatetruecolor($dyn_width, 50);
    
    imagealphablending($image, false);
    imagesavealpha($image, true);
    
    $foreground = imagecolorallocate($image, 56, 101, 157);
    $shadow = imagecolorallocate($image, 255, 255, 255);
    $background = imagecolorallocatealpha($image, 255, 255, 255, 127);
    //$transparent = imagecolorallocatealpha($image, 255, 255, 255, 127);
    
    imagefilledrectangle($image, 0, 0, $dyn_width, $dyn_width, $background);
    //imagefilledrectangle($image, 0, 0, $dyn_width, $dyn_width, $transparent);
    
    // use your own font!
    $font = '../fonts/STEAK.ttf';
    
    //draw text:
    imagettftext($image, 46, 0, 16, 39, $shadow, $font, $CLAN_NAME);
    imagettftext($image, 46, 0, 12, 42, $foreground, $font, $CLAN_NAME);     
}

// Just draw a single pixel if we have nothing
else {
    $image = imagecreatetruecolor(1, 1);
    $background = imagecolorallocatealpha($image, 255, 255, 255, 127);
    imagefilledrectangle($image, 0, 0, 1, 1, $background);
}    

//send image to browser
header ("Content-type: image/png");
imagepng($image);
imagedestroy($image);

?>